package com.zpark.merchant.app.controller;

import com.zpark.jushanpay.common.domain.PageVO;
import com.zpark.jushanpay.common.domain.RestResponse;
import com.zpark.jushanpay.common.util.SecurityUtil;
import com.zpark.merchant.api.dto.StoreDTO;
import com.zpark.merchant.api.service.IMerchantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @PackageName: com.zpark.merchant.app.controller
 * @ClassName: StoreController
 * @Description:
 * @author: RZS
 * @date: 2024/6/4  16:53
 */
@RestController
@RequestMapping("/store")
public class StoreController {

    @Autowired
    private IMerchantService merchantService;


    /**
     * 根据商户id查询门店信息
     * @param pageNo 起始页号
     * @param pageSize 每页的大小
     * @return
     */
    @GetMapping("/find_store_by_mid")
    public RestResponse<PageVO<StoreDTO>> findStoreByMerchantId(Integer pageNo, Integer pageSize){
        // 1、获取token，解析数据
        Long merchantId = SecurityUtil.getMerchantId();

        // 创建dto对象
        StoreDTO dto = new StoreDTO();
        dto.setMerchantId(merchantId);


        // 2、调用业务层接口查询门店信息
        PageVO<StoreDTO> storeDTOS = merchantService.queryStoreByMerchantId(dto, pageNo, pageSize);

        return RestResponse.success(storeDTOS);
    }
}
